package cn.shengongying.admin.controller;

import cn.shengongying.admin.dto.PositionInDTO;
import cn.shengongying.bean.DataTablePageResult;
import cn.shengongying.model.BossPosition;
import cn.shengongying.service.IBossPositionService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * author: RXK
 * date: 2022/2/19 星期六
 * desc:
 */
@Controller
@RequestMapping("/sys/position")
public class PositionController {


    private final IBossPositionService bossPositionService;

    public PositionController(IBossPositionService bossPositionService) {
        this.bossPositionService = bossPositionService;
    }


    @RequestMapping("/index")
    public String index(Long boss, Model model) {
        model.addAttribute("bossId", boss);
        return "/boss_position/index";
    }

    @ResponseBody
    @RequestMapping("/list")
    public DataTablePageResult<List<BossPosition>> list(@RequestBody PositionInDTO inDTO) {
        List<BossPosition> bossPositions = bossPositionService.findByBossId(inDTO.getBossId(), null);
        inDTO.setData(bossPositions);
        return inDTO;
    }
    
}
